import { defHttp } from '../http'
import type {
  AddUser,
  DeleteUser,
  EditUser,
  LoginRecord,
  LoginRecordParams,
  UserModel
} from '../model/user'
import type { BaseListResp } from './response'

export const userInfoApi = () => defHttp.get<UserModel>('/mock/user/info')

export const userListApi = (params: Recordable = {}) =>
  defHttp.get<BaseListResp<UserModel[]>>('/v1/admin', { params })
/** 添加管理员  */
export const add_user = (params: AddUser) =>
  defHttp.post<BaseListResp<any>>('/v1/admin', { params })
/** 编辑管理员  */
export const edit_user = (params: EditUser) =>
  defHttp.put<BaseListResp<any>>(`/v1/admin/${params.id}`, { params })
/** 删除管理员  */
export const delete_user = (params: DeleteUser) =>
  defHttp.delete<BaseListResp<any>>(`/v1/admin/${params.id}`)
/** 重置密码  */
export const reset_pwd = (params: DeleteUser) =>
  defHttp.put<BaseListResp<any>>(`/v1/admin/password`, { params })
/** 登录记录  */
export const login_record_list = (params: LoginRecordParams) =>
  defHttp.get<BaseListResp<LoginRecord>>(`/v1/admin_login_record`, {
    params
  })
